const mongoose = require("mongoose");
const leaveSchema = mongoose.Schema({
    orderNo: String, // 审批单号
    applyType: Number, // 审批类型
    startTime: {
        // 申请开始时间
        type: Date,
        default: Date.now,
    },
    endTime: {
        // 申请结束时间
        type: Date,
        default: Date.now,
    },
    applyUser: {
        // 申请人
        userId: String,
        userName: String,
        userEmail: String,
    },
    leaveTime: String, // 申请天数
    reasons: String, // 申请理由
    auditUsers: String, // 完整审批人
    curAuditUserName: String, // 当前审批人
    auditFlows: [
        // 审批流
        {
            userId: Number,
            userName: String,
            userEmail: String,
        },
    ],
    auditLogs: [
        // 审批日志
        {
            userId: Number,
            userName: String,
            createTime: {
                type: Date,
                default: Date.now,
            },
            remark: String,
            action: String,
        },
    ],
    applyState: {
        // 审批结果
        type: Number,
        default: 1,
    },
    createTime: {
        // 审批创建时间
        type: Date,
        default: Date.now,
    },
});

module.exports = mongoose.model("leaves", leaveSchema);
